#include <stdio.h>
#include <stdlib.h>
#include "ourhdr.h"
#include "analysis.h"
#include "def.h"
int main(int argc, char* argv[])
{
	char buf[MAXLINE];
	char suffixExpression[MAXLINE];
	char opStack[MAXLINE];
	double num[MAX_NUM];
	int n;
	double result;
	memset(opStack,0,MAXLINE);
	printf("->");
	while (fgets(buf,MAXLINE,stdin) != NULL)
	{
		buf[strlen(buf) - 1] = 0; /* replace new line with null*/ 
		if (strcmp(buf,"quit")== 0)
			break;
		memset(suffixExpression,0,MAXLINE);
		n = 0;
		AnalizeStr(buf,suffixExpression,opStack,num,&n);
		result = caculate_expression(suffixExpression,num,n);
		//printf("%s\n",buf);
		//printf("%s\n",suffixExpression);
		printf("Result is:%f\n",num[0]);
		printf("->");
	}
	
	exit(0);
}
